package com.example.figurehecheng.controller.merchant;


import com.example.figurehecheng.common.result.Result;
import com.example.figurehecheng.domain.dto.MerchantPasswordDTO;
import com.example.figurehecheng.domain.dto.MerchantRegisterDTO;
import com.example.figurehecheng.service.IMerchantService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 宇科工作室
 * @since 2024-10-18
 */
@RestController
@Slf4j
@Api(tags = "注册")
@CrossOrigin
@RequestMapping("/merchant/merchant")

public class MerchantController {

  @Resource
  private IMerchantService iMerchantService;

    /**
     * 管理端注册
     * @param merchant
     */
    @ApiOperation("商户注册")
    @PostMapping("/register")
     public void registerUser(@RequestBody MerchantRegisterDTO merchant){
        iMerchantService.register(merchant);
     }

    /**
     * 获取验证码
     * @param phone
     */
     @ApiOperation("获取验证码")
     @GetMapping ("/code")
     public void getCode(@RequestParam String phone){
         iMerchantService.code(phone);
     }


    /**
     * 商户登录
     * @param merchant
     */
    @PostMapping("/test")
    public Result<String> login(@RequestBody MerchantRegisterDTO merchant){
        return Result.success(iMerchantService.login(merchant));
    }

    /**
     * 忘记密码
     */
    @PostMapping("/password")
    @ApiOperation("忘记密码")
    public void updatePassword(@RequestBody MerchantPasswordDTO merchantPasswordDTO){
    iMerchantService.updatePassword(merchantPasswordDTO);
    }
}
